package do1.mobo.widget;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TableRow;

public class GridViewWidget extends TableLayout
{
	public GridViewWidget(Context context)
	{
		super(context);
		
		setGravity(Gravity.CENTER);
	}
	
	public void setAdapter(GridViewAdapter adapter)
	{
		final int Columns=3;
		
		int count=adapter.getCount();
		for(int i=0;i<count;i+=Columns)
		{
			TableRow tableRow=new TableRow(getContext());
			
			for(int j=0;j<Columns && i+j<count;j++)
			{
				View view=adapter.getView(i+j,null,null);
				tableRow.addView(view);
			}
		    addView(tableRow);
		}
	}
}
